package org.example.queueadmin.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class ApplicationStartupListener {
    
    private final SystemConfigService configService;
    
    @EventListener(ApplicationReadyEvent.class)
    public void onApplicationReady() {
        log.info("Initializing system configurations...");
        try {
            configService.initializeDefaultConfigs();
            log.info("System configurations initialized successfully");
        } catch (Exception e) {
            log.error("Failed to initialize system configurations: {}", e.getMessage(), e);
        }
    }
}
